$(function () {
    obj.init();
});

var obj = new function () {
    return {
        dataGrid_in: null,
        dataGrid_out: null,
        init: function () {
            id = xhTool.getQuery('goodsId');
            this.dataGrid_in = new xhDataGrid($('#inList'), 'lm/goods/getGoodsInDetail/true', {id: id});
            this.dataGrid_out = new xhDataGrid($('#outList'), 'lm/goods/getGoodsOutDetail/true', {id: id});
            this.dataGrid_in.parseToolbar().init();
            this.dataGrid_out.parseToolbar().init();
            xhExtra.clearLoadSuccess(this.dataGrid_in);
            xhExtra.clearLoadSuccess(this.dataGrid_out);
            this.listener();
        },
        listener: function () {
            var $this = this;
            //查询
            $('#bt_in_search').click(function () {
                $this.funObj().searchList($this.dataGrid_in,'in');
            });
            $('#bt_out_search').click(function () {
                $this.funObj().searchList($this.dataGrid_out,'out');
            });
        },
        funObj: function () {
            return {
                searchList: function (_dom, _type) {
                    id = $('#list_vague');
                    if (_type === 'in'){
                        id = $('#in_search');
                    } else if (_type === 'out'){
                        id = $('#out_search');
                    }
                    _dom.reload({
                        search: {
                            vague: xhExtra.getValue(id)
                        }
                    })
                }
            }
        }
    }
};